<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="/static/thirdparty/forge-dist-0.7.1/forge.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
    <script type="text/javascript" src="/static/common/config.js"></script>
    <script>
      var userInfo = {
        cookies: (Cookies.raw = true) && Cookies(),
        isLogin: false,
        params: {},
        fossParams:{}
      };
      var $ = {
        each:function (data,cb) {
          for(var i = 0;i < data.length;++i){
            cb(i,data[i]);
          }
        }
      }
      function setCookieToUserInfo(){
        if (userInfo.cookies['_TOKENUUMS'] && userInfo.cookies['TGC'] && userInfo.cookies['U']) {
          $.each(forge.util.decodeUtf8(forge.util.decode64(userInfo.cookies['_TOKENUUMS'])).split(','),
            function (index, item) {
              switch (index) {
                case 2:
                  userInfo.empCode = item;
                  break;
                case 3:
                  userInfo.deptCode = item;
                  break;
                case 4:
                  userInfo.deptName = item;
                  break;
              }
            });
          if (userInfo.empCode && userInfo.deptCode) {
            userInfo.isLogin = true;
          } else {
            window.location.href = UAP_SERVER_NAME + 'error.html';
            return;
          }
          if (userInfo.cookies['_TOKEN']) {
            $.each(forge.util.decodeUtf8(forge.util.decode64(userInfo.cookies['_TOKEN'])).split(','),
              function (index, item) {
                switch (index) {
                  case 3:
                    userInfo.optDeptCode = item;
                    break;
                  case 4:
                    userInfo.optDeptName = item;
                    break;
                }
              });
          }
          if (!userInfo.optDeptCode) {
            userInfo.optDeptCode = userInfo.deptCode;
            userInfo.optDeptName = userInfo.deptName;
          }
        } else {
          window.location.href = MENUCORE_SERVICE_URL + 'home';
          return;
        }
        if (userInfo.cookies['_TOKENUUMS']) {
          userInfo.params['_TOKENUUMS'] = userInfo.cookies['_TOKENUUMS']
            .replace(/\+/, '-')
            .replace(/\//, '_');
        }
        if (userInfo.cookies['_TOKEN']) {
          userInfo.params['_TOKEN'] = userInfo.cookies['_TOKEN']
            .replace(/\+/, '-')
            .replace(/\//, '_');
        }
        if(userInfo.cookies['exptoken']){
          userInfo.fossParams['exptoken'] = userInfo.cookies['exptoken']
            .replace(/\+/, '-')
            .replace(/\//, '_');
        }else{
          //ECS半小时之后_TOKENUUMS取值不到,exptoken 弥补
          userInfo.fossParams['exptoken'] = userInfo.params['_TOKENUUMS'];
        }
        if (userInfo.cookies['TGC']) {
          userInfo.params['TGC'] = userInfo.cookies['TGC'];
        }
        if (userInfo.cookies['TU']) {
          userInfo.params['TU'] = userInfo.cookies['TU'];
        }
        if (userInfo.cookies['U']) {
          userInfo.params['U'] = userInfo.cookies['U'];
        }
      }
      setCookieToUserInfo();
    </script>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta charset="utf-8">
    <title>业务门户系统</title>
    <script type="text/javascript" src="/static/thirdparty/jquery-1.12.4-dist/jquery.js"></script>
    <script type="text/javascript" src="/static/ext-dpap/scripts/ext-all.js"></script>
    <script type="text/javascript" src="/static/ext-dpap/scripts/ext-dpap.js"></script>
    <script type="text/javascript" src="/static/ext-dpap/scripts/ext-lang-zh_CN-min.js"></script>
    <script type="text/javascript" src="/static/common/ext-uap.js"></script>
    <script src="/static/com.js"></script>
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
    <div id="app"></div>
  </body>
  <script type="text/javascript" src="/static/resources/js/menuSupport.js"></script>
  <script type="text/javascript" src="/static/resources/js/biCriticalData.js"></script>
</html>
